package com.totem.admin.api;

import com.totem.admin.vo.FileUrlVO;
import com.totem.base.model.PageVO;
import com.totem.base.model.Result;
import com.totem.product.vo.*;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.Valid;
import java.io.IOException;

@Tag(name="AdminProductServiceApi", description="产品信息后台服务")
public interface AdminProductServiceApi {
    @PostMapping("/admin/product/create")
    @ResponseBody
    Result<Boolean> create(@RequestBody @Valid ProductCreateVO vo);

    @PostMapping("/admin/product/update")
    @ResponseBody
    Result<Boolean> update(@RequestBody @Valid ProductUpdateVO vo);

    @Operation(summary="查询商品详情")
    @GetMapping("/admin/product/getInfoById")
    @ResponseBody
    Result<ProductVO> getInfoById(@RequestParam(name="productId") Long productId);

    @Operation(summary="分页展示产品列表")
    @PostMapping("/admin/product/page")
    @ResponseBody
    Result<PageVO<ProductVO>> productPage(@RequestBody @Valid ProductPageVO vo);

    @Operation(summary="删除产品")
    @PostMapping("/admin/product/delete")
    @ResponseBody
    Result<Boolean> delete(@RequestBody @Valid ProductDeleteVO vo);

    @Operation(summary="产品上下架")
    @PostMapping("/admin/product/shelf")
    @ResponseBody
    Result<Boolean> shelf(@RequestBody @Valid ProductShelfVO vo);

    @Operation(summary="上传封面文件", description="")
    @PostMapping(value="/admin/product/upload/file/cover", consumes= MediaType.MULTIPART_FORM_DATA_VALUE)
    @ResponseBody
    Result<FileUrlVO> uploadFileCover(@RequestPart(value="file") MultipartFile file) throws IOException;

    @Operation(summary="上传轮播文件", description="")
    @PostMapping(value="/admin/product/upload/file/carousel", consumes=MediaType.MULTIPART_FORM_DATA_VALUE)
    @ResponseBody
    Result<FileUrlVO> uploadFileCarousel(@RequestPart(value="file") MultipartFile file) throws IOException;

    @Operation(summary="上传视频文件", description="")
    @PostMapping(value="/admin/product/upload/file/video", consumes=MediaType.MULTIPART_FORM_DATA_VALUE)
    @ResponseBody
    Result<FileUrlVO> uploadFileVideo(@RequestPart(value="file") MultipartFile file) throws IOException;
}
